//
//  FortuneDetailController.m
//  SmileWeather
//
//  Created by lanou3g on 15/9/23.
//  Copyright (c) 2015年 陶天海. All rights reserved.
//

#import "FortuneDetailController.h"

@interface FortuneDetailController ()
@property (nonatomic, strong)UIImageView *imageView;
@property (nonatomic, assign)BOOL isTap;


@property (nonatomic, strong)UIBarButtonItem *loadBtn;
@end

@implementation FortuneDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.imageView = [[UIImageView alloc] initWithFrame:kBounds];
    [_imageView sd_setImageWithURL:[NSURL URLWithString:self.model.path]];
    _imageView.userInteractionEnabled = YES;
    [self.view addSubview:_imageView];
    
    //给背景加手势
    UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImage)];
    [gesture setNumberOfTouchesRequired:1];
    [_imageView addGestureRecognizer:gesture];
    self.isTap = YES;
    
    [self setBtn];
}
- (void)tapImage{
    if (self.isTap == YES) {
        [UIView animateWithDuration:0.2 animations:^{
            self.navigationController.navigationBar.hidden = YES;
        } completion:nil];
        self.isTap = NO;
    }else{
        [UIView animateWithDuration:0.2 animations:^{
            self.navigationController.navigationBar.hidden = NO;
        }];
        self.isTap = YES;
    }

}
- (void)setBtn{
//    self.loadBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:(UIBarButtonSystemItemBookmarks) target:self action:@selector(deleteBtn)];
    self.loadBtn = [[UIBarButtonItem alloc] initWithTitle:@"删除" style:(UIBarButtonItemStyleDone) target:self action:@selector(deleteBtn)];
    self.navigationItem.rightBarButtonItem = self.loadBtn;
}
- (void)deleteBtn{
    [self.imageView removeFromSuperview];
    [[PlayerDataBase shareDataBase]deleteFortunePaperModelPath:self.model.path];
    [self.navigationController popViewControllerAnimated:YES];
    [self.collectionView reloadData];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
